package LeetCode.leetcode153;

class Solution {
    /** 0,1,2,3,4,5,6
     * [4,5,6,7,0,1,2]
     * @param nums
     * @return
     */
    public int findMin(int[] nums) {
        int left = 0;
        int right = nums.length - 1;
        while (left <= right) {
            int mid = left + (right - left) / 2;
            if (mid - 1 < 0 || nums[mid] < nums[mid - 1]) return  nums[mid];
            //在左边
            if (nums[mid]>= nums[left]){
                left = mid + 1;
            }else{
                right = mid - 1;
            }
        }
        return  nums[left];
    }
}